package com.power.controller;

import com.alibaba.fastjson.JSON;
import com.power.ov.ResultDataTable;
import com.power.service.LineService;
import com.power.service.impl.LineServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * User: 李辽
 * Date: 2020/10/08 16:32
 * Description:根据用户输入的线路编号和线路运行状态查找线路
 * Version: V1.0
 */
@WebServlet("/searchLine.do")
public class SearchLine extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String line_number = request.getParameter("line_number");//获取管理员输入的线路编号
        int line_run = Integer.parseInt(request.getParameter("line_run"));//获取该线路的运行状态
        int  page = Integer.parseInt(request.getParameter("page"));
        int  limit = Integer.parseInt(request.getParameter("limit"));

        System.out.println("进入后台  线路编号"+line_number);

        response.setContentType("application/json;charset=utf-8");
        LineService lineService = new LineServiceimpl();
        ResultDataTable resultDataTable = null;
        try {
            resultDataTable = lineService.SearchLine(line_number,line_run,page,limit);
            response.getWriter().write(JSON.toJSONString(resultDataTable));
            response.getWriter().flush();
            response.getWriter().close();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}













